program FibDyn;

const
   maxN = 45;
	  
var
   M : array[1..maxN] of cardinal;
     
function F(eN :  integer) : cardinal;
var t : integer;
begin
   t := eN;
   if M[eN] <> 0 then F := M[eN];
   if eN < 0 then F := 0;
   if eN > 1 then
      begin
	 t := F(eN-1)+F(eN-2);
	 M[eN] := t;
	 F := M[eN];
      end;
end; { F }

var n : integer;
begin 
   n := 3;
   write('F(',n ,') = ', F(n));
end.
